﻿<Window x:Class="ManageCategoriesProducts.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ManageCategoriesProducts"
        Title="MainWindow" Height="361" Width="525">
    <Window.Resources>
        <local:ConvertSelectionToBool x:Key="converterIsEnabled" />        
        <local:ConvertBooleanToIsEnabled x:Key="convertBooleanToIsEnabled" />
    </Window.Resources>
    <Grid>
        <TabControl Height="287" HorizontalAlignment="Left" Margin="12,12,0,0" Name="tabControlMain" 
                    VerticalAlignment="Top" Width="479">
            <TabItem Header="Categories" Name="tabItemCategories">
                <Grid>
                    <DataGrid AutoGenerateColumns="False" Height="188" HorizontalAlignment="Left" Margin="6,6,0,0" 
                              Name="dataGridCategories" VerticalAlignment="Top" Width="457" IsReadOnly="True"
                              SelectionMode="Single">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Category" Width="*" Binding="{Binding Path=CategoryName}" />                                                 
                        </DataGrid.Columns>
                    </DataGrid>
                    <Button Content="Edit" Height="23" HorizontalAlignment="Left" Margin="87,200,0,0" 
                            Name="buttonEditCategory" VerticalAlignment="Top" Width="75" 
                            IsEnabled="{Binding ElementName=dataGridCategories, Path=SelectedItem, 
                            Converter={StaticResource ResourceKey=converterIsEnabled}}" Click="buttonEditCategory_Click" />
                    <Button Content="Delete" Height="23" HorizontalAlignment="Left" Margin="168,200,0,0" 
                            Name="buttonDeleteCategories" VerticalAlignment="Top" Width="75" 
                            IsEnabled="{Binding ElementName=dataGridCategories, Path=SelectedItem, 
                            Converter={StaticResource ResourceKey=converterIsEnabled}}" Click="buttonDeleteCategories_Click" />
                    <Button Content="Add" Height="23" HorizontalAlignment="Left" 
                            Margin="6,200,0,0" Name="buttonAddCategory" VerticalAlignment="Top" Width="75" Click="buttonAddCategory_Click" />
                </Grid>
            </TabItem>
            <TabItem Header="Products" Name="tabItemProducts">
                <Grid>
                    <DataGrid Height="188" HorizontalAlignment="Left" Margin="6,6,0,0" AutoGenerateColumns="False"
                              Name="dataGridProducts" VerticalAlignment="Top" Width="457" IsReadOnly="True"
                              SelectionMode="Single">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Product"  Binding="{Binding Path=ProductName}" />
                            <DataGridTextColumn Header="Description" Binding="{Binding Path=Description}" />
                            <DataGridTextColumn Header="Category" Binding="{Binding Path=Category.CategoryName}" />
                            <DataGridTextColumn Header="Price" Binding="{Binding Path=Price, StringFormat=c}" />                            
                        </DataGrid.Columns>
                    </DataGrid>
                    <Button Content="Edit" Height="23" HorizontalAlignment="Left" Margin="87,200,0,0" 
                            Name="buttonEditProduct" VerticalAlignment="Top" Width="75" 
                            IsEnabled="{Binding ElementName=dataGridProducts, Path=SelectedItem, 
                            Converter={StaticResource ResourceKey=converterIsEnabled}}" Click="buttonEditProduct_Click" />
                    <Button Content="Delete" Height="23" HorizontalAlignment="Left" Margin="168,200,0,0" 
                            Name="buttonDeleteProduct" VerticalAlignment="Top" Width="75" 
                            IsEnabled="{Binding ElementName=dataGridProducts, Path=SelectedItem, 
                            Converter={StaticResource ResourceKey=converterIsEnabled}}" Click="buttonDeleteProduct_Click" />
                    <Button Content="Add" Height="23" HorizontalAlignment="Left" 
                            Margin="6,200,0,0" Name="buttonAddProduct" VerticalAlignment="Top" Width="75" Click="buttonAddProduct_Click" />
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
